package com.demo2do.fms.admin.service.authority;

import java.util.List;

import com.demo2do.core.entity.page.Page;
import com.demo2do.fms.admin.entity.search.authority.UserSearch;
import com.demo2do.fms.admin.service.DataService;
import com.demo2do.fms.entity.authority.Organization;
import com.demo2do.fms.entity.authority.RoleTemplate;
import com.demo2do.fms.entity.authority.User;
import com.demo2do.fms.entity.supplier.common.Supplier;

/**
 * 
 * @author Ysy
 *
 */
public interface UserService extends DataService<User>{
    
    /**
     * get user by loginName
     * 
     * @param loginName
     * @return
     */
    public User load(String loginName);
    
    /**
     * count user by role_templates
     * 
     * @param roleTemplates
     * @return
     */
    public int count(RoleTemplate[] roleTemplates);
    
    /**
     * @param search
     * @return
     */
    public int count(UserSearch search);
    
    /**
     * @param supplier
     * @return
     */
    public List<User> list(Supplier supplier);
    
    /**
     * list users by role_templates and page
     * 
     * @param roleTemplates
     * @param page
     * @return
     */
    public List<User> list(RoleTemplate[] roleTemplates, Page page);
    
    /**
     * @return
     */
    public List<User> list();
    
    /**
     * @param search
     * @param page
     * @return
     */
    public List<User> search(UserSearch search, Page page);
    
    /**
     * check user whether exist by loginName
     * 
     * @param loginName
     * @return
     */
    public boolean existLoginName(String loginName);
    
    /**
     * create user
     * 
     * @param user
     * @param operator
     */
    public void create(User user, Long operator);
    
    /**
     * create user and create user_supplier_relation
     * 
     * @param user
     * @param organizations
     * @param operator
     */
    public void create(User user, List<Organization> organizations, Long operator);
    
    /**
     * @param user
     * @param organizations
     * @param operator
     */
    public void createAdminUser(User user, List<Organization> organizations, Long operator);
    
    /**
     * @param user
     * @param operator
     */
    public void createBranchUser(User user, Long operator);
    
    /**
     * @param user
     * @param operator
     */
    public void createFmsUser(User user, Long operator);
    
    /**
     * 
     * @param user
     * @param operator
     */
    public void createSponsorUser(User user, Long operator);
    
    /**
     * @param user
     * @param operator
     */
    public void createSupplierUser(User user, Long operator);
    
    /**
     * 
     * @param user
     * @param operator
     */
    public void edit(User user, Long operator);
    
    /**
     * 修改总部、分区用户
     * @param user
     * @param operator
     */
    public void editAdminOrBranch(User user, Long operator);
    
    /**
     * disable user
     * 
     * @param user
     * @param operator
     */
    public void delete(User user, Long operator);
    
    /**
     * 删除总部或分区用户
     * @param user
     * @param operator
     */
    public void deleteAdminOrBranch(User user, Long operator);
    
    /**
     * 
     * @param user
     * @param password
     * @param operator
     */
    public void resetPassword(User user, String password, Long operator);
    
    /**
     * edit user_supplier_relation
     * 
     * @param user
     * @param organizations
     * @param operator
     */
    public void editOrganization(User user, List<Long> organizations, Long operator);
    
    /**
     * check password whether valid
     * 
     * @param user
     * @param existPassword
     * @return
     */
    public boolean checkExistPassword(User user, String existPassword);

    /**
     * edit password
     * 
     * @param user
     * @param password
     * @param operator
     */
    public void editPassword(User user, String password, Long operator);

}
